//
//  main.m
//  字符串的转换
//
//  Created by wenjim on 17/10/23.
//  Copyright © 2017年 WenJim. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    
    
    NSString * str = @"abc";
    
    // 1.将字符串转换为大写
    /*
    NSString * newStr = [str uppercaseString];
    NSLog(@"newStr = %@",newStr);
    */
    
    // 2.将字符串转换为小写
    /*
    NSString * newStr2 = [newStr lowercaseString];
    NSLog(@"newStr2 = %@",newStr2);
    */
    // http://www.xiaoningle.com/img/logo.png
    
    // 3.将字符串的首字符转换为大写
    /*
    NSString * newStr3 = [str capitalizedString];
    NSLog(@"newStr3 = %@",newStr3);
    */
    
    // 4. 字符串与基本数据类型的转换
    NSString * str1 = @"110";
    NSString * str2 = @"120";
    // str1 + str2; // 错误
    int value1 = [str1 intValue];
    int value2 = [str2 intValue];
    NSLog(@"sum = %i",value1 + value2);
    
    NSLog(@"length = %lu",str2.length);
    
    
    // 注意: 如果不是int,double,float,bool,integer,longlong这些类型就不要乱用
    NSString * str3 = @"12a";
    int value3 = [str3 intValue];
    NSLog(@"value3 = %i",value3);
    
    // 5.C语言字符串和OC字符串之间的转换
    char * cStr = "cwj";
    NSString * str5 = [NSString stringWithUTF8String:cStr];
    NSLog(@"str5 = %@",str5);
    
    NSString * str6 = @"cwjLove";
    const char * cStr2 = [str6 UTF8String];
    NSLog(@"cStr2 = %s",cStr2);
    
    return 0;
}
